package com.wuliu.web.controller.system;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuliu.common.annotation.Log;
import com.wuliu.common.core.controller.BaseController;
import com.wuliu.common.core.domain.AjaxResult;
import com.wuliu.common.enums.BusinessType;
import com.wuliu.system.domain.SysWeixinConfig;
import com.wuliu.system.service.ISysWeixinConfigService;
import com.wuliu.common.utils.poi.ExcelUtil;
import com.wuliu.common.core.page.TableDataInfo;

/**
 * 微信参数Controller
 * 
 * @author ruoyi
 * @date 2023-09-23
 */
@RestController
@RequestMapping("/system/wxconfig")
public class SysWeixinConfigController extends BaseController
{
    @Resource
    private ISysWeixinConfigService sysWeixinConfigService;

    /**
     * 查询微信参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:wxconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWeixinConfig sysWeixinConfig)
    {
        sysWeixinConfig.setSysAccount(getSysAccount());
        startPage();
        List<SysWeixinConfig> list = sysWeixinConfigService.selectSysWeixinConfigList(sysWeixinConfig);
        return getDataTable(list);
    }

    /**
     * 导出微信参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:wxconfig:export')")
    @Log(title = "微信参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWeixinConfig sysWeixinConfig)
    {
        List<SysWeixinConfig> list = sysWeixinConfigService.selectSysWeixinConfigList(sysWeixinConfig);
        ExcelUtil<SysWeixinConfig> util = new ExcelUtil<SysWeixinConfig>(SysWeixinConfig.class);
        util.exportExcel(response, list, "微信参数数据");
    }

    /**
     * 获取微信参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wxconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sysWeixinConfigService.selectSysWeixinConfigById(id));
    }

    /**
     * 新增微信参数
     */
    @PreAuthorize("@ss.hasPermi('system:wxconfig:add')")
    @Log(title = "微信参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWeixinConfig sysWeixinConfig)
    {
        sysWeixinConfig.setAccount(getSysAccount());
        return toAjax(sysWeixinConfigService.insertSysWeixinConfig(sysWeixinConfig));
    }

    /**
     * 修改微信参数
     */
    @PreAuthorize("@ss.hasPermi('system:wxconfig:edit')")
    @Log(title = "微信参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWeixinConfig sysWeixinConfig)
    {
        return toAjax(sysWeixinConfigService.updateSysWeixinConfig(sysWeixinConfig));
    }

    /**
     * 删除微信参数
     */
    @PreAuthorize("@ss.hasPermi('system:wxconfig:remove')")
    @Log(title = "微信参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysWeixinConfigService.deleteSysWeixinConfigByIds(ids));
    }
}
